Skip to main content

Available utilities

Components

We provide a component that allows you to render its children if a feature is active. In this exemple, <YourComponentToRender /> will be rendered only if the feature cart_revamp is active.

import { FlaghubFeature } from "flaghub-reactjs";

<FlaghubFeature reference="cart_revamp">
<YourComponentToRender />
</FlaghubFeature>;

Hooks

We provide a hook that allows you to know if a feature is active.

import { useFlaghub } from "flaghub-reactjs";

export const YourComponent = () => {
const { isFeatureActive } = useFlaghub();

if (isFeatureActive("cart_revamp")) {
console.log("I am active");
} else {
console.log("I am inactive");
}

...
};

Miscellaneous

For some cases (in automated testing for instance), you might want to activate a feature "on the fly". You can achieve that with our attached window instance.

window.flaghub.setFeatureActive("cart_revamp");